@extends('layouts.admin')
@push('morecss')
    <!-- jsTree -->
    <link href="{{ asset('/vendor/jstree/style.min.css') }}" rel="stylesheet">
@endpush
@push('morescript')
    <!-- Jquery Validate -->
    <script src="{{ asset('/vendor/jquery-validation/dist/jquery.validate.min.js') }}"></script>
    <script src="{{ asset('/vendor/jquery-validation/dist/localization/messages_zh.js') }}"></script>
    <!-- Jquery Form -->
    <script src="{{ asset('/vendor/jquery/jquery.form.min.js') }}"></script>
    <!-- jsTree -->
    <script src="{{ asset('/vendor/jstree/jstree.min.js') }}"></script>
    <script type="application/javascript">
        let page_params = {
            @can('admin.syspermission.index')
            url_list: '{{ route('admin.syspermission.index') }}',
            @endcan
            url_save: '{{ route('admin.syspermission.save') }}',
            url_get: '{{ route('admin.syspermission.get') }}',
            url_del: '{{ route('admin.syspermission.destroy') }}',
            url_sort: '{{ route('admin.syspermission.savesort') }}',
        };
    </script>
    <!-- require page js -->
    <script src="{{ mix('js/admin/syspermission_index.js') }}"></script>
@endpush
@section('content')
    <!-- 主体内容 -->
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-md-4">
                <div id="nestable-menu">
                    @can('admin.syspermission.save')
                    <button type="button" class="btn btn-primary add"><i class="fa fa-plus"></i>新增
                    </button>
                    <button type="button" class="btn btn-primary addchild"><i class="fa fa-plus"></i>添加子项
                    </button>
                    <button type="button" class="btn btn-primary edit"><i class="fa fa-pencil"></i>编辑
                    </button>
                    @endcan
                    @can('admin.syspermission.destroy')
                    <button type="button" class="btn btn-danger del"><i class="fa fa-trash-o"></i>删除
                    </button>
                    @endcan
                </div>

            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>权限列表</h5>
                    </div>
                    <div class="ibox-content">
                        <p class="m-b-lg">
                            你可以通过鼠标右键选择<b>增加子项、编辑、删除</b>操作，你还可以通过<b>拖拽</b>来调整权限所属层级及顺序。
                        </p>
                        <div id="jstree">
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

<!-- 权限编辑层 -->
<div class="ibox-content" id="box-form" style="display: none">
    <form role="form" id="form" action="{{ route('admin.syspermission.save') }}">
        <input type="hidden" name="perm_id" id="perm_id" value="0">
        <input type="hidden" name="parent_id" id="parent_id" value="0">
        <div class="form-group">
            <label>权限名</label>
            <input type="text" placeholder="例如：admin.index.index" class="form-control" name="name" required>
            <span class="help-block m-b-none">该名称用于定义权限，一般与路由名称一致</span>
        </div>
        <div class="form-group">
            <label>权限显示名</label>
            <input type="text" placeholder="输入权限规则" class="form-control" name="display_name" id="display_name"
                   required>
            <span class="help-block m-b-none">该名称用于查看</span>
        </div>
        <div class="form-group">
            <label>描述</label>
            <textarea class="form-control" placeholder="输入描述" name="description" id="description"></textarea>
            <span class="help-block m-b-none">权限说明</span>
        </div>
        <div class="form-group">
            <label>是否为公共权限</label>
            <div class="i-checks"><label><input type="radio" name="is_public" value="1"> <i></i>是</label></div>
            <div class="i-checks"><label><input type="radio" name="is_public" value="0" checked> <i></i> 否</label>
            </div>
            <span class="help-block m-b-none">选择是表示该权限无需验证，全局可用</span>
        </div>
        <div class="form-group">
            <label>是否展开</label>
            <div class="i-checks"><label><input type="radio" name="is_opentree" value="1" checked> <i></i>是</label>
            </div>
            <div class="i-checks"><label><input type="radio" name="is_opentree" value="0"> <i></i> 否</label></div>
            <span class="help-block m-b-none">是否展开子节点，用于权限管理页的展开</span>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-4">
                <button class="btn btn-primary" type="button" id="btn-sub">
                    保存
                </button>
            </div>
        </div>
    </form>
</div>

@endsection